# -*- coding: utf-8 -*-
"""
Created on Sat Oct 06 11:52:07 2012

@author: Tomek
"""
import namespace
import sys
#sys.argv[1]==compiled namespace name
ns=None

if len(sys.argv)!=2:
    #only for debug
    if namespace._DEBUG_:
        ns=namespace.loadNamespace("_ns_")
else:
    fullpath=""
    for p in range(1,len(sys.argv)):
        fullpath=fullpath+" "+sys.argv[p]
    ns=namespace.loadNamespace(fullpath)
def writeClass(c):
    print ("CLASS")
    print (c["name"])
    for x in c["public"]["classes"]:
        writeClass(x)
    for x in c["protected"]["classes"]:
        writeClass(x)
    for x in c["private"]["classes"]:
        writeClass(x)
    print ("ENDCLS")
def writeNamespace(n):
    if n["name"]!="":
        print ("NAMESPACE")
        print (n["name"])
    for t in n["namespaces"]:
        writeNamespace(t)
    for t in n["classes"]:
        writeClass(t)
    for t in n["functions"]:
        if t["isOperator"]==False:
            print ("FUNCTION")
            print (t["name"])
    for t in n["enums"]:
        print ("ENUM")
        print (t["name"])
    if n["name"]!="":
        print ("ENDNS")
        
        
writeNamespace(ns)
print "CLOSE_STREAM_PYTHON"